<?php


namespace common\event;


use app\common\model\LoginLog;
use think\facade\Db;

class User
{
    public function login($user)
    {
        $userAgent = request()->header("user-agent") ?: "";
        Db::table(LoginLog::getTable())->insert([
            "uid" => $user['uid'],
            "os" => $user['os'],
            "username" => $user['username'],
            "ip" => $user['ip'],
            "useragent" => $userAgent,
            "login_time" => $user['time'],
            "tenant_id" => $user['tenant_id'] ?? "",
        ]);
    }
}